package com.job.bytedance;

import java.util.Arrays;
import java.util.Scanner;

/**
 * @ClassName: ByteDance2_1
 * @Description:
 * @Author: 12071
 * @Date: 2022/4/24 14:34
 */
public class ByteDance2 {
    static int[] stepX = {-1,1,0,0};
    static int[] stepY = {0,0,-1,1};
    static int[][] seats;
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        seats = new int[n][m];
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < m; j++) {
                seats[i][j] = sc.nextInt();
            }
        }
//        for (int[] line : seats) {
//            System.out.println(Arrays.toString(line));
//        }
        int max=0;
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < m; j++) {
                if(seats[i][j]==0){
                    max = Math.max(max,itIsMySeat(n,m,i,j));
                }
            }
        }
        System.out.println(max);
    }

    public static int itIsMySeat(int n, int m, int x ,int y){
        int count=1;
        seats[x][y] = 1;
        for (int i = 0; i < 4; i++) {
            int a = x+stepX[i];
            int b = y+stepY[i];
            if(a>=0 && a<n && b>=0 && b<m && seats[a][b] == 0){
                count+=itIsMySeat(n,m,a,b);
            }
        }
        return count;
    }
}
